#include "Game.h"

Game::Game(void)
{
	Weapon* initWeapon = new Weapon("Sword of Justice", 50, 25);
	Game::AddWeapon(initWeapon);

	Armor* initArmor = new Armor("Crappy Breat Plate", 0, 5);
	Game::AddArmor(initArmor);
}

void Game::Run()
{
	Game::StartMenu();
	Game::GameMenu();
}

void Game::DisplayStartMenu()
{
	cout << "Welcome to the Arena Battler" << endl;
	cout << "(1) New Game" << endl;
	cout << "(2) Load Game" << endl;
	cout << "(0) Exit" << endl;
}

void Game::DisplayGameMenu()
{
	system("cls");
	cout << "Welcome " << player.GetName() << "!\n" << endl;
	cout << "(1) Inventory" << endl;
	cout << "(2) Arena" << endl;
	cout << "(3) Store" << endl;
	cout << "(0) Exit" << endl;
	cout << "\nWhere would you like to go?\n";
}

void Game::StartMenu()
{
	Game::DisplayStartMenu();

	int startMenuPrompt;
	Prompt(startMenuPrompt);

	switch(startMenuPrompt)
	{
	case 1:
		Game::NewPlayer();
		break;
	case 2:
		//LoadGame();
		break;
	default:
		exit(0);
		break;
	}
}

void Game::GameMenu()
{
	int menuInput;
	do
	{
		Game::DisplayGameMenu();

		Game::Prompt(menuInput);

		switch(menuInput)
		{
		case 1:
			//Inventory();
			break;
		case 2:
			//Arena();
			break;
		case 3:
			//Store();
			break;
		default:
			break;
		}
	}while(menuInput != 0);
}

void Game::NewPlayer()
{
	string name;
	cout << "\nEnter desired name: ";
	Game::Prompt(name);
	Player* newPlayer = new Player(name, Game::weapons[0], Game::armors[0]);
	Game::player = *newPlayer;
}

void Game::AddWeapon(Weapon* newWeapon)
{ 
	Game::weapons.push_back(newWeapon); 
}

void Game::AddArmor(Armor* newArmor)
{ 
	Game::armors.push_back(newArmor); 
}

void Game::Prompt(int &promptVar)
{
	do 
	{
		cin >> promptVar;
		cin.clear();
		cin.ignore(100, '\n');
	} while (cin.fail());
}

void Game::Prompt(string &promptVar)
{
	do 
	{
		cin >> promptVar;
		cin.clear();
		cin.ignore(100, '\n');
	} while (cin.fail());
}

Game::~Game(void)
{
}
